package com.iuhao.orange.controller;

import com.iuhao.orange.domain.mapper.AppDictionaryMapper;
import com.iuhao.orange.domain.model.AppDictionary;
import com.iuhao.orange.service.IAppDictionaryService;
import com.iuhao.orange.template.RedisTemplates;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2018/8/8.
 */
@Api(tags = "TestController", description = "项目测试类")
@RestController
@RequestMapping("/test")
public class TestController extends BaseController {

    @Autowired
    private IAppDictionaryService appDictionaryService;

    @Autowired
    private AppDictionaryMapper appDictionaryMapper;

    @Autowired
    private RedisTemplates redisTemplates;

    @RequestMapping(value = "/test/{id}", method = RequestMethod.POST)
    @ApiOperation(value = "测试数据字典")
    public AppDictionary checkPhone(@PathVariable("id") Integer id, HttpServletRequest request) {
        //AppDictionary dictionary = appDictionaryMapper.selectById(id);
        AppDictionary dictionary = appDictionaryService.selectById(id);
        return dictionary;
    }


    @RequestMapping(value = "/testRedis", method = RequestMethod.POST)
    @ApiOperation(value = "redis测试")
    public String testUpload() {
        redisTemplates.put("iuhaotest", "18300684211", 1000, false);
        String iuhaotest = redisTemplates.get("iuhaotest");
        return iuhaotest;
    }

}
